# islogin=False
# def add_shoppingcart():
# 	while True:
# 		global islogin
# 		if islogin:
# 			goodsName=int(input('请选择你要的商品：1.羊羽羽；2.米田共；3.尸米。'))
# 			if goodsName == 1 or 2 or 3:
# 				if goodsName==1:
# 					goodsName='羊羽羽'
# 					price='三毛钱'
# 					print('你想买{}，需要付{}'.format(goodsName,price))
# 				elif goodsName==2:
# 					goodsName='米田共'
# 					price="五分钱"
# 					print('你想买{}，需要付{}'.format(goodsName,price))
# 				elif goodsName==3:
# 					print('你想买尸米，免费。')				
# 				break
# 			else:
# 				print('没有选中商品')
# 		else:
# 			answer=input('用户没有登录，是否登录用户？（是/否）')
# 			if answer=='是':
# 				username=input('输入用户名：')
# 				password=input('输入密码：')
# 				islogin=login(username,password)
# 			else:	
# 				print('很遗憾！没有添加任何商品')
# def login(username,password):
# 	if username=='小屁孩'and password=='123456':
# 		return True
# 	else:
# 		return print('用户名或密码错误。')
# 		return False
# print('欢迎光临')
# add_shoppingcart()

# def A(b):
# 	a=100
# 	print(a)
# 	def B():
# 		nonlocal a
# 		for x in range(b):
# 			a+=1
# 			print(x,a)
# 		print(a)
# 	return B
# c=A(5)
# c()

# def A(m):
# 	print('在A里')
# 	m()
# 	def C():
# 		print('在C里')
# 		m()
# 	def Z():
# 		print('在Z里',Z)
# 		m()
# 	return Z	
# 	return C
# 	return print('返回值')
# def D(m):	
# 	print('在D里')
# 	m()
# 	def G():
# 		print('在G里')
# 		m()
# 	return G
# def B():
# 	print('在B里')
# 	print(type(B))
# @A
# @D
# @A
# def E():
# 	print('在E里')
# print(E)
# @A
# def F():
# 	print('成功\n将C调出来')
# F()
# B()
# E()

# import time
# def decorate(func):
# 	def warpper(*args,**kargs):    #万能装饰器
# 		print('在校验中...')
# 		time.sleep(0.5)
# 		print('校验完毕...')
# 		func(*args,**kargs)
# 	return warpper
# @decorate
# def f1(n):
# 	print('---f1---',n)
# f1(5)
# @decorate 
# def f2(name,age):
# 	print("---f2---",name,age)
# f2('lily',20)
# @decorate
# def f3(students,clazz='死亡班级'):
# 	for stu in students:
# 		print(stu,clazz)
# students=['lily','tom','lucy']
# f3(students,clazz='高兴班级')

# 威威='wie '
# print(威威)

# A='我'  
# B='你'  
# print('%s看着%s'%(A,B))
# print(A in B)

# A=['0','1','2','3','4','5']
# B=('0','1','2','3','4','5')
# print(A[1:5],B[::-3])
# print(bin(10),oct(10),int(10),hex(20))
# A=31>>2
# print(3&2,6|3,7^5,5<<2,%fA)
# for i in range(-10,10):
# 	pass
# 	print(~i)    #都以二进制的形式：当i>0,先取反再减1，再取反；当i<0,先取反再加1，再取反。(简单的理解就是将坐标轴倒过来，-1变成第一位即0)

# A=2638135456 
# B=2638135456
# print(id(A),id(B))
# print(A is B,A==B)
# s={a,b,c,d,english,apple}
# A=*s.find(a)
# print(A)

# A='1434sdf'
# B='1434sdf'
# C='f'
# d=A+C
# print(id(A),id(B))
# if A is B:
# 	print('A,B名和id都一样')
# elif A==B:
# 	print('A，B名一样')
# else:
# 	print('A,B完全不同')
# print(A is B)

# name='Hello123'
# print('上了' in name)

# a=name.rfind('课',5,len(name))
# print(a,name.isalpha(),name.isalnum())
# b=name.replace('上','s')
# c=name.encode('utf-8')  
# d=c.decode('utf-8')
# e=name.startswith('Hallo') and name.endswith('a')
# f=name.endswith('!')
# g='-'.join(name)
# print(g,e)
# print(a,b,c,d,e,f)

'''切割和删去'''
# a='  . Hello how are you?  ..a. '
# b=a.rstrip(' ')
# # b=a.split('.')
# b+='8'
# print(type(b),b)
# print(type(range(7)),range(7))

'''怎么将列表的东西修改和删除。'''
# words=['hello','goods','go','word','digot','alpha']
# w=input('输入一个单词：')
# i=0
# l=len(words)
# while i<l:
# 	if w in words[i]:
# 		del words[i]
# 		l-=1
# 		continue
# 	i+=1
# words[0]='你好'
# del words[2]
# words.append('how')
# words.extend('ABC')
# words.insert(-1,'my name is ...')
# print(words)

# set1=['就as',{'中db':1,'gg':2},('在ec','dg'),['d','a']]
# print(sum(set1))
# print(sorted(set1,reverse=True))
# print(set1[2][0])
# a=[3,4,4,5,6,7,9,11,13,15,17]
# *_,c=a
# print(_,*_,c)       #_可用字母代替
# a.clear()
# print(a)
# print(a[-2: :-1],sum(a))
# print(a.count(4),a.index(11))
# del a[1]
# a.remove(3)
# print(a.pop(4))
# print(a)
# b=[]
# c=[]
# for x in range(5,2,-1):
# 	c.append(x)
# 	b.append(a[x])
# print(b,c)
# a=[1,'d',3]
# b,c,d=a
# print(b,c,d)

# dict0=dict({(1,2),(3,4),(5,6)})
# print(tuple(dict0.values()),dict0.items(),dict0.keys())
# A=(0)
# print(type(A),type(dict0.items()))
# b=dict0.pop(1)
# d=dict0.popitem()
# a=[1,4,2,0,3]
# del a[1]
# a.pop(1)
# # a.remove()
# print(dict0,a,b,d)
# e={'字':'典'}
# g=[7,8,9,10,11]
# dict0.update(e)
# f=dict.fromkeys(a,g)
# print(e,dict0,f)

# b={1:0,2:3};c={4:5,6:7};print(type(b),b.update(c),b)
# a={'a','b',1,3,2};b=3,2,'b'
# print(a.pop(),a);print(a.discard(b),a);a.clear();print(a)
# d={(1,'a'),(4,'c'),(3,'d'),(2,'b')};l=(1,3,'5','6',4,2,'b','f','e','a');print(sorted(l,key=lambda x:x[0]),sorted(d,key=lambda x:x[0],reverse=True))
# a=open(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\新1.txt','w')
# print(a.read('来来来'))

# import os,random,time
# print(os.path);path=os.path.dirname(__file__)		;print(path,type(path))
# with open	(r'F:\background\035432nxq3h3633qbmkabp.jpg','rb') as A:         #读取路径文件1.jpg的二进制格式(bytes)缓存入流A(格式：_io.BufferedReader)
# 	a=A.read() ;print(A.name)                      #用a接收A的内容
# 	b=A.name;c=b[b.rfind('\\'):];print(c)
# 	p=os.path.join(path,'2.jpg');print(p)      #'2.jpg'可以用p,p是保留原名及格式
# 	with open(p,'wb') as B:                   #以二进制形式新建文件2.jpg在路径0并缓存入流B,如果2.jpg文件存在则内容全部删除重新改写
# 		B.write(a)	                       #流B将文件2.jpg写成a的内容
# d=os.path.isabs(p);print(d)
# a=os.getcwd();b=os.path.join(a,'字典.txt');print(os.path.splitext(b))
# b=os.path.isabs(r'F:\kuwo\kuwomusic\9.0.7.0_BDS2\Uninstall.exe');print(b)
# os.removedirs(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\New folder')
# os.remove(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\a\l.txt')
# os.mkdir(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\a.txt')

# import os ; # print(os.getcwd())#;os.chdir(r'D:\pycharm doc');print(os.getcwd())
# a=os.path.abspath(__file__) #;print(os.path.abspath('wi10激活.txt'))
# print(os.path.split(a),os.path.splitext(a))
# print(os.path.dirname(__file__))

# with open(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\b.txt','rb') as A:
# 	a=()
# 	for x in range(2):
# 		a+=A.readline();print(a)#,end='')
# 		with open(r'C:\Users\Administrator\Desktop\学习资料\c.txt','wb') as B:
# 			B.write(a)

# C=open(r'C:\Users\Administrator\Desktop\win10激活、快捷键、电脑修改\b.txt','rb')
# for x in C.readline():
# 	D=open(r'C:\Users\Administrator\Desktop\学习资料\c.txt','wb')
# 	D.write(x)

# def a():
# 	try:
# 		a = int(input('输入数字:'))
# 		# return 1
# 	except Exception as err:
# 		print(err)
# 		return 2
# finally:
# 	print('最后')
# 	return 3
# 	else:
# 		return print('干嘛啊~~~~赫赫~~')
# x=a() ; print(x)

# a=None
# if a:
# 	print('有a',a)
# else:
# 	print('没a',a)

# a=['Lily','Tom','July','James','boys'] ; b=[name.capitalize() if len(name)>3 for name in a] ; print(b)
# a=[(x,y) for x in range(4) if x%2==0 for y in range(5) if y%2!=0 ] ; print(a)
# d={'a':1,'b':2,'c':3} ; d2=d.items();print(set(d2),type(d2))#d1={x:y for y,x in d.items()};print(d,d1)
# a=(x*3 for x in range(10)) ;print(a.__next__()) ; print(next(a)) ; ...  #用(),每a.__next__()就调用一次遍历的结果。

# def A():
# 	for n in range(5):
# 		temp=yield n 
# 		print('temp:',temp)
# 		# n += 1
# 	return '没有更多'
# g=A();print(g.send(None)) ;m1=g.send('第一次');print(m1)#;m2=g.send('第二次');print(m2);print(g.send('第二次'));print(g.send('第二次'));	
# a=False ;print(isinstance(a,bool))
# a=None;print(a)
#
# class cat:
# 	"""docstring for A"""
# 	food='蟑螂'
# 	name='傻猫'
# 	def cat_information(s,play):
# 		s.play=play
# 		s.food='蟑螂1'
# 		print(s.food,s.friend)
# 	def __init__(s,num1):
# 		s.food='老鼠' ;print(num1)
# 		s.friend='调皮狗'
# 		s.play='球'
# 	@classmethod
# 	def catch(cls):
# 		cls.food='老鼠1' ;print(cls.food)
# 	@staticmethod
# 	def mouse1():
# 		cat.food1='小老鼠' ;print(cat.food)
# 	@staticmethod
# 	def run(play):
# 		#cat.food = '老鼠2'
# 		cat.play=play ; print(cat.food1)
# 		return cat.play
# 	def sleep(s,name,hour):
# 		print('{}睡了{}小时'.format(name,hour))
# 	def __new__(cls, num):
# 		new=object.__new__(cls);print(new)
# 		return new
# # cat1=cat();cat1.play='ball';cat1.cat_information();cat1.sleep('老虎',2)#;print(cat,cat1)
# cat1=cat(1);print(cat1);cat1.catch()#;cat1.cat_information('bool1') ;
# cat1.mouse1();cat1.run('boll')
# print(cat1,cat1.food,cat1.play)

# import sys
# class Person():
#     # gender='女1'# name='oomn' ; s=5 ; print(s)
#     def name1(self,*arg,**kwargs):
#         print('小孩',self.gender)
#     def __init__(self,name,age):
#         self.__name=name
#         self.__age=age
#         gender='女'
#     def set_age(self,age):
#         if 0 < age <= 100:
#             self.__age=age
#         else:
#             print('年龄不符或超神')
#     def gsffiv(self):
#         return self.__age,self.__name,self.gender
#     def set_name(self,name):
#         if len(name) <= 6:
#             self.__name=name
#         else:
#             print('名字必须小于六位')
#     def get_name(self):
#         return self.__name,self.__age#,self.gender,print('na')

#     def __del__(self):
#         print(self.__name,'自动删除你的角色')
#     def __call__(self,*arg,**kwargs):
#         pass
#     def __str__(self):
#         return '姓名：{},年龄：{}'.format(self.__name,self.__age)
# # p=Person('JACK');p.name1() ;print(p,Person,Person.name1)
# # p1=p;p2=p ;p1.name1() ; print(sys.getrefcount(p),sys.getrefcount(Person))
# # del p1,p2 ; print(sys.getrefcount(p),sys.getrefcount(Person))
# p3=Person("hissfssafs",125);p3.set_name('mshrhrhhan');#;p3.__name='uiy,'  #注意: p3.__name='uiy,'是外部创建属性,跟类没关系
# p3.set_age(120);
# # p3.gender="男";
# # print(p3.gsffiv());
# # p3.name1()
# # p3.__init__('sjfi',90)
# print(p3.get_name(),p3)#,priceson.__name)
# # print(dir(Person)) ;print(dir(p3));print(p3._Person__name) ; print(p3.__dir__());print(__name__)

# import sys
# class Person():
#     def __init__(self,name,age):
#         self.__name=name
#         self.__age=age
#         gender='女'
#     @property
#     def age(self):
#         return self.__age
#     @age.setter
#     def age(self,age):
#         if age>0 and age<100:
#             self.__age=age
#         else:
#             print('输入年龄不符或超神')
#     def __str__(self):
#         return '姓名：{},年龄：{}'.format(self.__name,self.__age)
# p1=Person('小明',-10);p1.age=30
# print(p1.age);
# print(p1)#p1.age(50);
# # print(dir(Person)) ;print(dir(p1));
# # print(p1._Person__name) ; print(p1.__dir__());
# # print(__name__)

# class Computer:
#     def __init__(self,brand,type,color):
#         self.brand=brand
#         self.type=type
#         self.color=color
#     def online(self):
#         print('正在使用电脑上网')
#     def __str__(self):
#         return self.brand+'--sf-'+self.type+'-yh-'+self.color
# class Book:
#     def __init__(self,bname,author,number):
#         self.bname=bname
#         self.author=author
#         self.number=number
#     def __str__(self):
#         return self.bname+'-sd'+self.author+'-i-'+str(self.number)
# class Students:
#     def __init__(self,name,computer,book):
#         self.name=name
#         self.computer=computer
#         self.books=[]
#         self.books.append(book)
#     def borrow_book(self,book):
#         for book1 in self.books:
#             if book1.bname == book.bname:
#                 print('已经借过此书');break
#         else:
#             self.books.append(book);print('添加成功')
#     def show_book(self):
#         for book in self.books:
#             print(book.bname)
#     def __str__(self):
#         return self.name+'--fs-'+str(self.computer)+'----'+str(self.books)
# c=Computer('小米','小米神机','浅灰色');b=Book('盗墓笔记','南派三叔',10);stu=Students('眼镜男',c,b);
# print(stu);stu.show_book()
# b1=Book('鬼吹灯','天下霸唱',8);stu.borrow_book(b1);
# print('--------------');stu.show_book()

# class Person1:
#     def __init__(self,name,age):
#         self.name=name;self.age=age+1
#     def eat(self,food):
#         print(self.name+'正在吃{}'.format(food))
#     def run(self):
#         print(self.name+'正在跑')
# class Person:
#     def __init__(self,name,age):
#         self.name=name;self.age=age
#     def eat(self,food):
#         print(self.name+'正在吃{}'.format(food))
#     def run(self):
#         print(self.name+'正在跑步')
# class Employee(Person,Person1):
#     def __init__(self,name,age,stature):
#     	self.stature=stature
#     	Person1.__init__(self,name,age)
# class Student(Person):
#     pass
# class Doctor(Person):
#     pass
# import inspect
# print(inspect.getmro(Employee));print(Employee.__mro__)
# s=Student('高材生',52);s.run();e=Employee('傻佬',50,'1.72米');print(e.age);d=Doctor('老双标',51);

# class A(object):
#     __instance=None
#     def __init__(self,y):
#         self.__x = 1 ; self.y=y
#     def print(self):
#         print(self.__x,self.y)
#     def __new__(cls,y):
#         if cls.__instance is None:
#             cls.__instance=object.__new__(cls)
#         return cls.__instance
#     def xie():
#         print('----')
# class B(A):
#     def __init__(self):
#         super().__init__()
#         self.__x = 2 ; self.y=20
#     # def print(self):
#     #     print(self.__x,self.y)
#     def __str__(self):
#         print(self.z+self.y)
# b=B();b.print();b.z=3;b.__str__()
# d=A(2);c=B(3);d.print();c.print();print(id(d),id(c))        
# import h2  ;print(h2.hi)

# import time ; print(time.time())

# class A():
#     __instance=None
#     def __init__(self,y):
#         self.__x = 1 ; self.y=y
#     def print(self):
#         print(self.__x,self.y)
#     def __new__(cls,y):
#         if cls.__instance is None:
#             cls.__instance=object.__new__(cls)
#         return cls.__instance
#     def xie(self,y):
#         print('----');return '写{}'.format(self.y)
#     def __str__(self):
#         return '字符串__'
# class B():
#     def __init__(self, x):
#         self.x = x
#     def show(self):
#         print('----');return '显{}'.format(self.x)
#     def __str__(self):
#         return '串串'
# a=A(1);b=B(a);print(b.x,b.show())

# # from new import *  
# # h.xie()

# # import sys,time ; print(sys.path);print(sys.version);print(sys.argv)
# import time;t2=time.time();s=time.localtime(t2);print(t2,time.ctime(t2),s,time.mktime(s))
# print(s.tm_yday,time.strftime('%Y-%m-%d %H:%M:%S',s))

# import datetime ; print(datetime.time.hour) #;print(time.localtime().tm_hour)
# d=datetime.date(2020,9,2);print(d.day);print(datetime.date.ctime(d));print(datetime.date.today())
# timedel=datetime.timedelta(hours=2);print(timedel) ;now=datetime.datetime.now();print(now)
# print(now-timedel)

# import hashlib ; msg='傻佬。。。傻佬' ; msg_sha512=hashlib.sha512('傻佬。。。傻佬'.encode('utf-8')) ;print(msg.encode('utf-8'),msg_sha512.hexdigest())
# m='傻佬' ; m_md5=hashlib.md5(m.encode('utf-8')) ;print(m_md5.hexdigest())

# import requests ; print(requests.get('https://www.12306.cn/').text)

# import re ; msg='娜扎佟丽娅热巴代斯' ;name=re.compile('佟丽娅') ;print(name.match(msg),re.match('佟丽娅',msg))
# result=re.search('佟丽娅',msg);print(result,result.span()) ;print(result.group(),result.groups())

# import re ;#msg='a4frr569ywef233tdn5547od6mv' ;result=re.findall('[a-z][0-9][a-z]',msg);print(result)
# qq='136565' ;result1=re.match(r'^[1-9][0-9]{3,5}$',qq);print(result1)
# username='ad5 ju 1 fish' ;result=re.findall(r'[^0-9]',username) ;print(result)
# msg=' 风格和stdgeffsf3465871#￥*sffsf36533\nj覆盖 ' ;result=re.findall(r'[sfae]\d{1,6}',msg) ;print(result))
# msg='<html><h1>asd</h1></ html>' ;result=re.search(r'<(?P<name1>\w+)><(?P<name2>\w+)>(.+)</(?P=name2)></\s(?P=name1)>',msg);print(result,result.group())	

# from multiprocessing import Process ;from time import sleep ;import os
# def task1():
# 	while True:
# 		sleep(1);print('任务1.....',os.getpid(),'----',os.getppid())
# def task2():
# 	while True:
# 		sleep(2);print('任务2.....',os.getpid(),'----',os.getppid())
# if __name__=='__main__':
# 	print(os.getpid())
# 	p1=Process(target=task1,name='任务1') ;p1.start() ;print(p1.name)
# 	p2=Process(target=task2,name='任务2') ;p2.start() ;print(p2.name)
# print(os.getpid(),'eeeeeeee') ;print('wwwww')

from multiprocessing import Pool ;import time ;from random import random ;import os
def task(task_name):
    print('开始做任务',task_name) ;start=time.time() ;time.sleep(random() * 2)
    end=time.time() ;return '完成任务:{}，用时：{},线程id:{},进程id:{}'.format(task_name,(end - start),os.getpid(),id(print))
container=[]
def callback_func(n):
	container.append(n)
if __name__ == '__main__':
    pool=Pool(5) ;tasks=['听音乐','练眼力','做饭','跑步','玩电脑','刷牙','遛狗']
    for i in tasks:
        pool.apply_async(task,args=(i,),callback=callback_func)
    pool.close() ;pool.join() ;
    # for c in container:
    	# print(c)
    print('完事')







































































